package com.example.controller.mobilecontroller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.config.ResponseVO;
import com.example.pojo.EnrollInfo;
import com.example.pojo.FamilyInfo;
import com.example.pojo.dto.FamilyStuDTO;
import com.example.pojo.dto.UserParentInfoDTO;
import com.example.service.FamilyInfoService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/mobile")
public class FamilyController {
    @Resource
    private FamilyInfoService familyInfoService;

    @PostMapping("/addOrUpdateFamily")
    public ResponseEntity<ResponseVO<String>> addOrUpdateFamily(@RequestBody FamilyInfo familyInfo) {
        String result = familyInfoService.addOrUpdateFamilyInfo(familyInfo);
        return ResponseEntity.ok(new ResponseVO<>(HttpStatus.OK,result));
    }

    @PostMapping("/selectFamilyByStuName/{famName}")
    public ResponseEntity<ResponseVO<UserParentInfoDTO>> selectFamilyByStuName(@PathVariable("famName") String famName){
       UserParentInfoDTO familyByname=familyInfoService.selectFamilyByStuName(famName);
        return ResponseEntity.ok(new ResponseVO<>(HttpStatus.OK, "用户信息获取成功", familyByname));
    }

    @PostMapping("/selectFamilyByStuId/{stuId}")
    public ResponseEntity<ResponseVO<List<FamilyInfo>>> selectFamilyByStuId(@PathVariable Long stuId){
       return familyInfoService.selectFamilyByStuId(stuId);
    }
}
